#include <stdio.h>
#include <string.h>
void *memory_copy(void *dst, void *src, int size)
{
	char *psrc = (char *)src, *pdst = (char *)dst;

	if (!psrc || !pdst) return NULL;
	if (size <= 0) return NULL;


	if (psrc < pdst && psrc+size > pdst) {
		psrc += size - 1;
		pdst += size - 1;
		while (size--) {
			*pdst-- = *psrc--;
		}
	} else {
		while (size--) {
			*pdst++ = *psrc++;
		}
	}

	return dst;	
}
char *string_copy(char *dst, char *src, int count)
{
	char *pdst = dst;
	if (!dst || !src || count <= 0) return NULL;
	while (count--) {
		if ((*dst++ = *src++) == '\0'){
			break;
		}
	}
	return pdst;
}
void main(int argc, char *argv[]) 
{
	/*char buf[] = "1234567890";
	void *p = (void *)buf;
	//printf("%p %c, %p %d, ++ %p, %p\n", buf,*buf, p, *(char *)p,  buf++, p++);
	memory_copy(p, p+4, 2);
	//memcpy(p, p+4, 2);
	printf("%s\n", buf);
	

	memory_copy(p, p+2, 4);
	printf("%s\n", buf);*/

	char dst[60];
	if (argc != 2) {
		printf("usage: strcpy <string>");
		return;
	}
	
	printf("%s\n", string_copy(dst, argv[1], 60));
}
